package com.cmbc.xiaodu.bill;

import com.baidu.dueros.bot.BaseBot;
import com.baidu.dueros.data.response.OutputSpeech;
import com.baidu.dueros.data.response.Reprompt;
import com.baidu.dueros.data.response.card.TextCard;
import com.baidu.dueros.model.Response;
import com.cmbc.xiaodu.BaseService;
import com.cmbc.xiaodu.MinShengBot;

public class BillService implements BaseService {
    private BaseBot baseBot;

    public BillService(MinShengBot baseBot) {
        this.baseBot = baseBot;
    }

    public Response ask(String slot) {
        if (slot.equals("userName")) {
            return this.askUserName();
        } else if (slot.equals("cardNum")) {
            return null;
        } else {
            return null;
        }
    }

    public Response compute() {
       /* // 获取多轮槽位值：月薪值、城市信息、查询种类
        String monthlysalary = getSlot("monthlysalary");
        String location = getSlot("location");
        String type = getSlot("compute_type");
        String ret = "月薪" + monthlysalary + "城市" + location + "个税种类" + type;

        TextCard textCard = new TextCard(ret);
        textCard.setAnchorText("setAnchorText");
        textCard.addCueWord("查询成功");

        setSessionAttribute("key_1", "value_1");
        setSessionAttribute("key_2", "value_2");

        OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, ret);

        Reprompt reprompt = new Reprompt(outputSpeech);

        // 主动结束会话
        this.endDialog();

        Response response = new Response(outputSpeech, textCard, reprompt);

        return response;*/
        return null;

    }

    /**
     * 用来处理用户名槽位返回模板
     *
     * @return
     */
    private Response askUserName() {
        TextCard textCard = new TextCard("您的税前工资是多少呢?");
        textCard.setUrl("www:......");
        textCard.setAnchorText("链接文本");
        textCard.addCueWord("您的税前工资是多少呢?");

        // 设置会话信息 TODO
//        setSessionAttribute("key_1", "value_1");
//        setSessionAttribute("key_2", "value_2");

        OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "你的名字是什么?");

        // 构造reprompt
        Reprompt reprompt = new Reprompt(outputSpeech);

        Response response = new Response(outputSpeech, textCard, reprompt);

        return response;

    }
}
